<div class="content-wrapper">

    <section class="content-header">
        <?php echo $this->partial('layout/breadcrumb'); ?>

        <h1 class="pull-right">
            <a href="<?php echo $this->url('user', ['action'=> 'add']);?>" class="btn btn-primary btn-sm"><i class="fa fa-plus"></i> <?php echo $this->translate('添加客户'); ?></a>
            <?php echo $this->HelpUrl('userList'); ?>
        </h1>

    </section>

    <section class="content">
        <?php echo $this->partial('layout/messages'); ?>

        <div class="row">
            <div class="col-xs-12">
                <div class="box shop-box">

                    <div class="box-body table-responsive no-padding">
                        <table class="table shop-table table-hover">
                            <thead>
                            <tr class="shop-bg-thead">
                                <th width="5%">ID</th>
                                <th><?php echo $this->translate('客户名称'); ?></th>
                                <th width="15%"><?php echo $this->translate('客户邮箱'); ?></th>
                                <th width="10%"><?php echo $this->translate('手机号码'); ?></th>
                                <th width="8%"><?php echo $this->translate('客户组'); ?></th>
                                <th width="8%"><?php echo $this->translate('余额'); ?></th>
                                <th width="10%"><?php echo $this->translate('消费/等级积分'); ?></th>
                                <th width="8%"><?php echo $this->translate('状态'); ?></th>
                                <th width="10%"><?php echo $this->translate('加入时间'); ?></th>
                                <th width="15%"><?php echo $this->translate('操作'); ?></th>
                            </tr>
                            <?php
                            $sForm = $this->searchForm;
                            $sForm->prepare();
                            $sForm->get('user_status')->setEmptyOption('状态');
                            ?>
                            <?php echo $this->form()->openTag($sForm); ?>
                            <tr>
                                <td>
                                    <p>
                                        <?php echo $this->formElement($sForm->get('start_id')); ?>
                                    </p>
                                    <div>
                                        <?php echo $this->formElement($sForm->get('end_id')); ?>
                                    </div>
                                    <?php echo $this->formElementErrors($sForm->get('start_id'), ['class'=>'error-message']);?>
                                    <?php echo $this->formElementErrors($sForm->get('end_id'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('user_name')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('user_name'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('user_email')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('user_email'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('user_phone')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('user_phone'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('user_group_id')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('user_group_id'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('user_money')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('user_money'), ['class'=>'error-message']);?>
                                </td>
                                <td></td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('user_status')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('user_status'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <p>
                                        <?php echo $this->formElement($sForm->get('start_time')); ?>
                                    </p>
                                    <div>
                                        <?php echo $this->formElement($sForm->get('end_time')); ?>
                                    </div>
                                    <?php echo $this->formElementErrors($sForm->get('start_time'), ['class'=>'error-message']);?>
                                    <?php echo $this->formElementErrors($sForm->get('end_time'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <button type="submit" class="btn btn-info btn-sm"><i class="fa fa-search"></i></button>
                                    <?php
                                    $formData = $sForm->getData();
                                    if(!empty(array_filter($formData))) { ?>
                                        &nbsp;&nbsp;<a href="<?php echo $this->url('user');?>" class="btn btn-default btn-sm"><i class="fa fa-reply"></i></a>
                                    <?php } $editFormData = array_merge([$formData], ['sPage' => $this->userList->getCurrentPageNumber()]); $formData['page'] = $this->userList->getCurrentPageNumber(); ?>
                                </td>
                            </tr>
                            <?php echo $this->form()->closeTag(); ?>
                            </thead>
                            <tbody>
                            <?php $phoneAreaCodeCount = count($this->phoneAreaCode); if($this->userList->getCurrentItemCount() > 0) foreach ($this->userList as $user) { ?>
                                <tr>
                                    <td><?php echo $user->getUserId(); ?></td>
                                    <td><?php echo $this->escapeHtml($user->getUserName()); ?></td>
                                    <td><?php echo $this->escapeHtml($user->getUserEmail()); ?></td>
                                    <td><?php echo !empty($user->getUserPhone()) ? ($phoneAreaCodeCount > 1 ? '+'.$this->phoneAreaCode[$user->getAreaCode()]['areaPhoneCode'] : '') . ' ' . $this->escapeHtml($user->getUserPhone()) : ''; ?></td>
                                    <td><?php echo $this->escapeHtml($user->getOneUserGroup()->getUserGroupName()); ?></td>
                                    <td>
                                        <?php echo $user->getUserMoney(); ?><br>
                                        <a href="<?php echo $this->url('user-balance', ['action' => 'editUserBalance', 'id' => $user->getUserId()], ['query' => $formData]); ?>" class="btn btn-xs btn-success"><?php echo $this->translate('调整'); ?></a>
                                    </td>
                                    <td>
                                        <?php echo $user->getIntegralType1Num() . '/' . $user->getIntegralType2Num(); ?><br>
                                        <a href="<?php echo $this->url('user-integral', ['action' => 'editUserIntegral', 'id' => $user->getUserId()], ['query' => $formData]); ?>" class="btn btn-xs btn-success"><?php echo $this->translate('调整'); ?></a>
                                    </td>
                                    <td><?php echo $this->userHelper()->userStatus($user->getUserStatus()); ?></td>
                                    <td><?php echo $this->shopDateFormat()->userAddTime($user->getUserAddTime()); ?></td>
                                    <td>
                                        <p>
                                            <a href="<?php echo $this->url('user',
                                                ['action'=>'edit', 'id'=>$user->getUserId()], ['query' => $editFormData]); ?>"
                                               class="btn btn-xs btn-success"><i class="fa fa-pencil"></i> <?php echo $this->translate('编辑'); ?></a>
                                            <a href="javascript:;" onclick="deleteConfirm('<?php echo $this->translate('您确实要删除该客户吗?'); ?>', '<?php echo $this->url('user', ['action'=>'delete', 'id'=>$user->getUserId()], ['query' => ['qToken' => $this->adminHelper()->getCsrfValue()]]); ?>');" class="btn btn-xs btn-danger"><i class="fa fa-trash"></i> <?php echo $this->translate('删除'); ?></a>
                                        </p>
                                        <p>
                                            <a href="<?php echo $this->url('user',
                                                ['action'=>'changeUserPassword', 'id'=>$user->getUserId()], ['query' => $formData]); ?>"
                                               class="btn btn-xs btn-success"><i class="fa fa-pencil"></i> <?php echo $this->translate('登录密码'); ?></a>
                                            <a href="<?php echo $this->url('user',
                                                ['action'=>'changePayPassword', 'id'=>$user->getUserId()], ['query' => $formData]); ?>"
                                               class="btn btn-xs btn-success"><i class="fa fa-pencil"></i> <?php echo $this->translate('支付密码'); ?></a>
                                        </p>
                                    </td>
                                </tr>
                            <?php } ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="box-footer clearfix">
                        <?php echo $this->paginationControl($this->userList, 'Sliding', 'layout/page', ['route' => 'user']); ?>
                    </div>
                </div>
            </div>
        </div>

    </section>
</div>
<script>
    laydate.render({elem: '#start_time'});
    laydate.render({elem: '#end_time'});
</script>